//
//  SuggestionViewController.m
//  jiyujiaProgram
//
//  Created by NiKi on 15/11/16.
//  Copyright © 2015年 中良 赵. All rights reserved.
//

#import "SuggestionViewController.h"

@interface SuggestionViewController () <UITextFieldDelegate,UITextViewDelegate>

@end

@implementation SuggestionViewController
{
    UITextView *_textView;
    UITextField *_textField;
    UILabel *_placehold;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self creatNavigationBarWithImage:nil title:@"意见反馈"];
    [self creatNavigationBarLeftItemWithLeftTitle:nil LeftImage:ECIMAGENAME(@"back_button.png")];

    [self creatView];
}


- (void)leftBtnClick:(id)leftSender
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)creatView
{
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 64, ECSCREEN_W - 40, 40)];
    titleLabel.text = @"日语+用户体验反馈QQ群:412412412";
    titleLabel.font = [UIFont systemFontOfSize:14.f];
    [self.view addSubview:titleLabel];
    
    UIView *resonView = [[UIView alloc] initWithFrame:CGRectMake(15, 104, ECSCREEN_W - 30, 150)];
    resonView.backgroundColor = ECCOLOR(255, 255, 255, 1);
    [self.view addSubview:resonView];
    
    _textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 5, ECSCREEN_W - 50, 140)];
    _textView.delegate = self;
    _textView.font = [UIFont systemFontOfSize:13.f];
    [resonView addSubview:_textView];
    
    _placehold = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, ECSCREEN_W - 60, 20)];
    _placehold.text = @"有什么不爽的请告诉我们吧";
    _placehold.textColor = [UIColor lightGrayColor];
    _placehold.font = [UIFont systemFontOfSize:13.f];
    [_textView addSubview:_placehold];
    
    UIView *contactView = [[UIView alloc] initWithFrame:CGRectMake(15, 264, ECSCREEN_W - 30, 40)];
    contactView.backgroundColor = ECCOLOR( 255, 255, 255, 1);
    [self.view addSubview:contactView];
    
    _textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 0, ECSCREEN_W - 50, 40)];
    _textField.delegate = self;
    _textField.placeholder = @"QQ/邮箱/手机号";
    _textField.font = [UIFont systemFontOfSize:13.f];
    [contactView addSubview:_textField];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(20, ECSCREEN_H - 50, ECSCREEN_W - 40, 40);
    button.backgroundColor = NAVC_COLOR;
    button.clipsToBounds = YES;
    button.layer.cornerRadius = 5;
    [button setTitle:@"提交" forState:UIControlStateNormal];
    [button setTitleColor:ECCOLOR(255, 255, 255, 1) forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:14.f];
    [button addTarget:self action:@selector(submitClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

- (void)submitClick:(UIButton *)button
{
    [_textField resignFirstResponder];
    [_textView resignFirstResponder];
    NSLog(@"*****SUBMITCLICK******");
}


- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

#pragma mark - touchesBegan
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [_textView resignFirstResponder];
    [_textField resignFirstResponder];
}

- (void)textViewDidBeginEditing:(UITextView *)textView
{
    _placehold.hidden = YES;
    _textField.userInteractionEnabled = NO;
}


- (void)textViewDidEndEditing:(UITextView *)textView
{
    if (textView.text.length == 0) {
        _placehold.hidden = NO;
    }
    _textField.userInteractionEnabled = YES;
}


- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    _textView.userInteractionEnabled = NO;
}


- (void)textFieldDidEndEditing:(UITextField *)textField
{
    _textView.userInteractionEnabled = YES;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
